package com.sky.mapper;

import com.sky.annotation.AutoFillCommonFields;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishItemVO;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface SetmealMapper {
    @Select("select count(*) from sky_take_out.setmeal where category_id = #{id}")
    Integer countByCategoryId(Long id);

    @AutoFillCommonFields(OperationType.INSERT)
    void save(Setmeal setmeal);

    List<SetmealVO> pageQuery(SetmealPageQueryDTO setmealPageQueryDTO);

    void deleteByIds(List<Long> ids);

    List<Setmeal> getByIds(List<Long> ids);

    @AutoFillCommonFields(OperationType.UPDATE)
    void update(Setmeal setmeal);

    @Delete("delete  from setmeal_dish where id = #{id} ")
    void deleteById(Long id);

    @Select("select * from setmeal where id = #{id}")
    Setmeal getbyId(Long id);


    List<Setmeal> getByCategoryId(Setmeal setmeal);

    List<DishItemVO> getDishItemListBySetmealId(Long setmealId);

    /**
     * 根据条件统计套餐数量
     * @param map
     * @return
     */
    Integer countByMap(Map map);
}
